<template>
	<view class="switch-container">
		<text>{{title}}</text>

			<radio-group v-if="type==2" @change="onRadioChange" class="switch-radio-box">
				<radio value="0" :checked="select==0?true:false">关</radio>
				<radio value="1" :checked="select==1?true:false">开</radio>
			</radio-group>
			<radio-group v-else-if="type==3" @change="onRadioChange" class="switch-radio-box">
				<radio value="0" :checked="select==0?true:false">关</radio>
				<radio value="1" :checked="select==1?true:false">中</radio>
				<radio value="2" :checked="select==2?true:false">高</radio>
			</radio-group>
            <radio-group v-else="type==4" @change="onRadioChange" class="switch-radio-box">
				<radio value="0" :checked="select==0?true:false">关</radio>
				<radio value="1" :checked="select==1?true:false">低</radio>
				<radio value="2" :checked="select==2?true:false">中</radio>
				<radio value="3" :checked="select==3?true:false">高</radio>
			</radio-group>

	</view>
</template>
<script>
	export default {
		props: {
			type: {
				type: Number,
				default: 2
			},
			title: {
				type: String,
				default: '开关状态：'
			},
			select: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				selected_index: 0,
			};
		},
		methods: {
			onRadioChange(e) {
				//console.log(e.detail.value)
				//console.log('tt')
				this.$emit('status', e.detail.value)
			},
		}
	};
</script>
<style lang="scss">
	.switch-container {
		display: flex;
		flex-direction: row;
		align-items: center;

		.switch-radio-box {
			display: flex;
			flex-direction: row;
			margin: 10rpx 10rpx 10rpx 10rpx;
			justify-content:space-around;
			flex-grow: 1;
		}
	}
</style>
